package com.ruoyi.web.controller.production.graftingclip;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import com.ruoyi.production.domain.graftingclip.GraftingclipPurchaseApply;
import com.ruoyi.production.service.graftingclip.IGraftingclipPurchaseApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 嫁接夹购买申请Controller
 *
 * @author ruoyi
 * @date 2021-07-11
 */
@RestController
@RequestMapping("/system/graftingclipApply")
@Api("嫁接夹购买申请")
public class GraftingclipPurchaseApplyController extends BaseController
{
    @Autowired
    private IGraftingclipPurchaseApplyService graftingclipPurchaseApplyService;

    /**
     * 查询嫁接夹购买申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:graftingclipApply:list')")
    @GetMapping("/list")
    @ApiOperation("查询嫁接夹购买申请列表")
    public TableDataInfo list(GraftingclipPurchaseApply graftingclipPurchaseApply)
    {
        startPage();
        List<GraftingclipPurchaseApply> list = graftingclipPurchaseApplyService.selectGraftingclipPurchaseApplyList(graftingclipPurchaseApply);
        return getDataTable(list);
    }

    /**
     * 导出嫁接夹购买申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:graftingclipApply:export')")
    @Log(title = "嫁接夹购买申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GraftingclipPurchaseApply graftingclipPurchaseApply)
    {
        List<GraftingclipPurchaseApply> list = graftingclipPurchaseApplyService.selectGraftingclipPurchaseApplyList(graftingclipPurchaseApply);
        ExcelUtil<GraftingclipPurchaseApply> util = new ExcelUtil<GraftingclipPurchaseApply>(GraftingclipPurchaseApply.class);
        return util.exportExcel(list, "嫁接夹购买申请数据");
    }

    /**
     * 获取嫁接夹购买申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:graftingclipApply:query')")
    @GetMapping(value = "/{graftingclipPurchaseApplyId}")
    public AjaxResult getInfo(@PathVariable("graftingclipPurchaseApplyId") Long graftingclipPurchaseApplyId)
    {
        return AjaxResult.success(graftingclipPurchaseApplyService.selectGraftingclipPurchaseApplyById(graftingclipPurchaseApplyId));
    }

    /**
     * 新增嫁接夹购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:graftingclipApply:add')")
    @Log(title = "嫁接夹购买申请", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    @ApiOperation("新增嫁接夹购买申请")
    public AjaxResult add(@RequestBody GraftingclipPurchaseApply graftingclipPurchaseApply)
    {
        return toAjax(graftingclipPurchaseApplyService.insertGraftingclipPurchaseApply(graftingclipPurchaseApply));
    }

    /**
     * 修改嫁接夹购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:graftingclipApply:edit')")
    @Log(title = "嫁接夹购买申请", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改嫁接夹购买申请")
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody GraftingclipPurchaseApply graftingclipPurchaseApply)
    {
        return toAjax(graftingclipPurchaseApplyService.updateGraftingclipPurchaseApply(graftingclipPurchaseApply));
    }

    /**
     * 删除嫁接夹购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:graftingclipApply:remove')")
    @Log(title = "嫁接夹购买申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{graftingclipPurchaseApplyIds}")
    @ApiOperation("删除嫁接夹购买申请")
    public AjaxResult remove(@PathVariable Long[] graftingclipPurchaseApplyIds)
    {
        return toAjax(graftingclipPurchaseApplyService.deleteGraftingclipPurchaseApplyByIds(graftingclipPurchaseApplyIds));
    }
}
